<?php namespace Phpcmf\Controllers\Admin;

class Shouye extends \Phpcmf\App
{

	public function index() {
		// 初始化模块
		//$this->_module_init(APP_DIR);
		
		$data = \Phpcmf\Service::M()->table('muban_qingchun_shezhi')->where('dirname', APP_DIR)->getRow();
		if (!$data) {
		    $this->_admin_msg(0, dr_lang('模块#%s不存在1', APP_DIR));
		}
		
		
		$data['setting'] = dr_string2array($data['setting']);
		if (!isset($data['setting']['pages'])) {
		    $data['setting']['pages'] = [];
		}
		
		if (IS_POST) {
		    $post = \Phpcmf\Service::L('input')->post('data');
		    $data['setting']['pages'] = $post;
		    \Phpcmf\Service::M()->db->table('muban_qingchun_shezhi')->where('dirname', APP_DIR)->update([
		        'setting' => dr_array2string($data['setting']),
		    ]);
		    $this->_json(1, '操作成功');
		}
		
		$page = intval(\Phpcmf\Service::L('input')->get('page'));
		//$this->fix_admin_tpl_path = dr_get_app_dir('module').'Views/';
		\Phpcmf\Service::V()->assign([
		    'page' => $page,
		    'form' => dr_form_hidden(['page' => $page]),
		    'data' => $data['setting']['pages'],
		    'menu' =>  \Phpcmf\Service::M('auth')->_admin_menu(
		        [
		            '参数配置' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-cog'],
		        ]
		    ),
		]);
		\Phpcmf\Service::V()->display('home.html');
		//\Phpcmf\Service::V()->display('shezhi.html');exit;
	}
	
}
